package com.zhuyi.broadcast.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhuyi.broadcast.mapper.DeviceCategoryMapper;
import com.zhuyi.broadcast.pojo.domain.DeviceCategory;
import com.zhuyi.broadcast.service.DeviceCategoryService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  设备类型实现类
 * </p>
 *
 * @author dyj
 * @since 2024-12-20
 */

@Service
public class DeviceCategoryServiceImpl extends ServiceImpl<DeviceCategoryMapper, DeviceCategory> implements DeviceCategoryService
{

    public List<DeviceCategory> list(String searchKey) {
        LambdaQueryWrapper<DeviceCategory> wrapper = Wrappers.lambdaQuery();
        wrapper.orderBy(true, false, DeviceCategory::getCreateTime);
        if (ObjectUtils.isNotEmpty(searchKey)) {
            wrapper.like(DeviceCategory::getCode, searchKey)
                    .or()
                    .like(DeviceCategory::getName, searchKey);
        }
        return baseMapper.selectList(wrapper);
    }
}
